Non Differentiality Test

7/2/2022




Agenda

  • New Assumption

    • New statistic
    • New data simulation
    • data.table implementation
  • Asymmetry

  • Literature




New Assumption

non-differential \(SE_{AUB}\) error

null hypothesis:

\[\begin{equation*} \frac{SE^{e=1}_A}{SE^{e=0}_A} = 1 \end{equation*}\]

\[\begin{equation*} \frac{SE^{e=1}_A}{SE^{e=0}_A} - 1 = 0 \end{equation*}\]

If:

\[\begin{equation*} SE^{e}_A = \frac{P^{e}_A \times PPV^{e}_A}{\pi^{e}} \end{equation*}\]

and if:

\[\begin{equation*} \pi^e = \frac{P_A^e \times PPV_A^e}{SE_{AUB}^e} + \frac{P_B^e \times PPV_B^e}{SE_{AUB}^e} - \frac{P_{A \cap B}^e \times PPV_{A\cap B}^e}{SE_{AUB}^e} \end{equation*}\]

then:

\[\begin{equation*} SE^{e=1}_A=\tfrac{P^{e=1}_A \times PPV^{e=1}_A}{\tfrac{P_A^{e=1} \times PPV_A^{e=1}}{SE_{AUB}^{e=1}} + \tfrac{P_B^{e=1} \times PPV_B^{e=1}}{SE_{AUB}^{e=1}} - \tfrac{P_{A \cap B}^{e=1} \times PPV_{A\cap B}^{e=1}}{SE_{AUB}^{e=1}}} \end{equation*}\]

\[\begin{equation*} SE^{e=0}_A=\tfrac{P^{e=0}_A \times PPV^{e=0}_A}{\tfrac{P_A^{e=0} \times PPV_A^{e=0}}{SE_{AUB}^{e=0}} + \tfrac{P_B^{e=0} \times PPV_B^{e=0}}{SE_{AUB}^{e=0}} - \tfrac{P_{A \cap B}^{e=0} \times PPV_{A\cap B}^{e=0}}{SE_{AUB}^{e=0}}} \end{equation*}\]

Defining:

\[\begin{align*} A^e &= P^{e=1}_A \times PPV^{e=1}_A \\ B^e &=P^{e=1}_B \times PPV^{e=1}_B \\ C^e &=P^{e=1}_{A \cap B} \times PPV^{e=1}_{A \cap B} \\ A^{\bar{e}} &= P^{e=0}_A \times PPV^{e=0}_A \\ B^{\bar{e}} &=P^{e=0}_B \times PPV^{e=0}_B \\ C^{\bar{e}} &=P^{e=0}_{A \cap B} \times PPV^{e=0}_{A \cap B} \\ S &= \tfrac{1}{SE_{AUB}^{e=0}} = \tfrac{1}{SE_{AUB}^{e=1}} \end{align*}\]

Replacing:

\[\begin{equation*} \frac{SE^{e=1}_A}{SE^{e=0}_A} = \frac{A^e}{S(A^e + B^e - C^e)} \times \frac{S(A^{\bar{e}} + B^{\bar{e}} - C^{\bar{e}})}{A^{\bar{e}}} = \frac{A^e(A^{\bar{e}} + B^{\bar{e}} - C^{\bar{e}})}{A^{\bar{e}}(A^e + B^e - C^e)} \end{equation*}\]

Replacing again:

\[\begin{equation} t = \frac{P^{e}_A PPV^{e}_A (P^{\bar{e}}_A PPV^{\bar{e}}_A + P^{\bar{e}}_B PPV^{\bar{e}}_B - P^{\bar{e}}_{A \cap B} PPV^{\bar{e}}_{A \cap B})}{P^{\bar{e}}_A PPV^{\bar{e}}_A (P^{e}_A PPV^{e}_A + P^{e}_B PPV^{e}_B - P^{e}_{A \cap B} PPV^{e}_{A \cap B})} - 1 \end{equation}\]




New data simulation

If \(SE_{AUB}=SE_A + SE_B + SE_{A \cap B}\), to respect the assumption it is necessary to set the parameters such that::

\[SE_A^e + SE_B^e + SE_{A \cap B}^e=SE_A^{ne} + SE_B^{ne} + SE_{A \cap B}^{ne}\]

sensitivity <- list(list(A_exposed = 0.4, A_non_exposed = 0.5, B_exposed = 0.6, B_non_exposed = 0.52),
                    list(A_exposed = 0.5, A_non_exposed = 0.5, B_exposed = 0.6, B_non_exposed = 0.6),
                    list(A_exposed = 0.6, A_non_exposed = 0.5, B_exposed = 0.6, B_non_exposed = 0.68))

data.table implementation

start_time <- Sys.time()

A = NA
A = ifelse(Y==1 & E==1, apply(dati, 1, function(SEe){rbinom(1, 1, SE_A_e)}),
           ifelse(Y==1 & E==0, apply(dati, 1, function(SEne){rbinom(1, 1, SE_A_ne)}), 
                  ifelse(Y==0 & E==1, apply(dati, 1, function(FPe){rbinom(1, 1, 1-SP_A_e)}), 
                         ifelse(Y==0 & E==0, apply(dati, 1, function(FPne){rbinom(1, 1, 1-SP_A_ne)}), A))))

B = NA
B = ifelse(Y==1 & E==1, apply(dati, 1, function(SEe){rbinom(1, 1, SE_B_e)}),
           ifelse(Y==1 & E==0, apply(dati, 1, function(SEne){rbinom(1, 1, SE_B_ne)}), 
                  ifelse(Y==0 & E==1, apply(dati, 1, function(FPe){rbinom(1, 1, 1-SP_B_e)}), 
                         ifelse(Y==0 & E==0, apply(dati, 1, function(FPne){rbinom(1, 1, 1-SP_B_ne)}), B))))

C = NA
C = A*B

end_time <- Sys.time()
time_taken <- end_time - start_time
time_taken
## Time difference of 0.7126479 secs
start_time <- Sys.time()

dati <- dati[Y==1 & E==1, A:=rbinom(dati[Y==1 & E==1, .N], 1, SE_A_e)]
dati <- dati[Y==1 & E==0, A:=rbinom(dati[Y==1 & E==0, .N], 1, SE_A_ne)]
dati <- dati[Y==0 & E==1, A:=rbinom(dati[Y==0 & E==1, .N], 1, 1-SP_A_e)]
dati <- dati[Y==0 & E==0, A:=rbinom(dati[Y==0 & E==0, .N], 1, 1-SP_A_ne)]

dati <- dati[Y==1 & E==1, B:=rbinom(dati[Y==1 & E==1, .N], 1, SE_B_e)]
dati <- dati[Y==1 & E==0, B:=rbinom(dati[Y==1 & E==0, .N], 1, SE_B_ne)]
dati <- dati[Y==0 & E==1, B:=rbinom(dati[Y==0 & E==1, .N], 1, 1-SP_B_e)]
dati <- dati[Y==0 & E==0, B:=rbinom(dati[Y==0 & E==0, .N], 1, 1-SP_B_ne)]

end_time <- Sys.time()
time_taken <- end_time - start_time
time_taken
## Time difference of 0.05404902 secs

Asymmetry

Combination